package com.daidai.activitys

import android.widget.ImageView
import androidx.activity.viewModels
import com.daidai.base.BaseActivity
import com.daidai.spinner.R
import com.daidai.tools.G
import com.helloandroid.uitween.UITweenModel
import com.helloandroid.uitween.composition.Repeat
import com.helloandroid.uitween.moveBy
import com.helloandroid.uitween.single.MoveBy

class TestTween : BaseActivity() {

    lateinit var icon:ImageView
    val tweenModel : UITweenModel by viewModels()
    override fun getContentViewResId(): Int = R.layout.activity_test_tween

    override fun initView() {
        tweenModel.startLoop()
        icon = findViewById(R.id.icon)

        var firstDraw = false
        icon.viewTreeObserver.addOnDrawListener {
            if (!firstDraw){
                G.elog("开始绘制....")
                val move = MoveBy(1f,0f,200f)
                    .moveBy(1f,0f,-200f)
                Repeat(-1,move).runBy(icon,tweenModel)
                firstDraw = true
            }
        }
    }

    override fun initData() {
    }
}